Repository navigation
Conversation
6d8fb3e to
7b5a541
Compare
|
Thanks for the efforts @Roman3349 I want to wait a bit with adding the 2020-12 draft as the 2019 draft is still gaining fixes and the test suite is just passing 91%. Besides that adding a new draft requires more work such as expanding the bowtie implementation and the documentation. Also I'm planning to review #931 soon whihc should be a good improvement for 2019 which we also need in 2020-12 if I'm not mistaken. So please bear with me on this PR as it might take some more time to see it through. |
3e660bd to
33fa118
Compare
19416ac to
c1d4673
Compare
d64c60c to
876a68c
Compare
|
To make the review easier, I've deduplicated the Draft 2020-12 constraints. Constraints that are the same as in Draft 2019-09 are now thin subclasses of the I've also rebased the branch onto the current |
|
Hi Roman, As explained earlier at this point I would rather duplicate classes (to avoid creating hybrid schema drafts which actually don't belong anywhere). So having Draft 2020-12 extends from 2019-09 goes against that. Ideally I want to merge 2020-12 support but with code duplication. Do you think you can make that change? The next mayor version (no plans yet) we could revisit this idea all together but for now I would rather keep the existing pattern. I'm a bit stuck for time but ill try and do my best to get this PR reviewed once changed. |
|
Done. The Draft 2020-12 constraints and its |
6af600b to
6abecfc
Compare
6abecfc to
bffc625
Compare
b8a750f to
1a98dfd
Compare
|
@Roman3349 a quick question did all the other PR's get ported into 2020-12 draft? An initial review by AI flagged some missing feature/fixes. Such as unevaluated items, ext intl check and the email format. |
|
Thanks for checking, it was right about two of them:
The email format is already covered: #1005 is part of this PR, and its changes are applied to Draft 2020-12 in 1a98dfd. Apart from the 2020-12 specific changes, The only Draft 2019-09 PR not ported is #984 ( |
…RFC 3986 and RFC 5321 Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
… address literals Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
…aft 2020-12 Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
…in Draft 2020-12 Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
5f14db7 to
cced2a8
Compare
Description
Adds basic support for Draft 2020-12, based on the Draft 2019-09 implementation. Only changes required by the 2020-12 specification are made. The motivation was to add the draft 2020-12 to validate the OpenAPI specification v3.1, which is a subset of the draft 2020-12.
Draft2020constraint set and adraft2020-12dialect registered inFactory. Following the existing pattern, the constraints and theFactoryare full copies of the Draft 2019-09 classes, not subclasses, and noDraft2019class is changed. OnlyItemsConstraint, the newPrefixItemsConstraint,FormatConstraint,FactoryandDraft2020Constraintdiffer from their Draft 2019-09 counterparts, apart from links to the specification.prefixItems/itemsas required by 2020-12:additionalItemsis removed and the array form ofitemsis replaced byprefixItems.PrefixItemsConstraintvalidates array items by position.itemsnow takes a single schema and only applies to items after those covered byprefixItems.dist/schema/json-schema-draft-2020-12.json, plus its URL mapping inUriRetriever.formatis an annotation by default, as 2020-12 requires (§7.2.1: assertion "MUST be disabled by default"). The newConstraint::CHECK_MODE_FORMAT_ASSERTIONflag enables it.CHECK_MODE_DISABLE_FORMATwins if both flags are set. Other drafts are not affected.draft2020-12in strict mode. Theoptional/formattests run withCHECK_MODE_FORMAT_ASSERTIONenabled.Draft 2019-09 changes merged into
mainwhile this PR was open are carried over to Draft 2020-12:unevaluatedProperties(feat: support unevaluatedProperties in Draft 2019-09 #931).$dynamicRefis not followed, the same way$recursiveRefis not in Draft 2019-09.EcmaPatternConverterforpattern,patternProperties,additionalPropertiesandunevaluatedProperties(Apply the same ECMA to PCRE pattern replacements everywhere #943), plus error path and ECMA pattern tests (fix: Report Draft-06/07 sub-schema errors at the property and item path #967, Apply the same ECMA to PCRE pattern replacements everywhere #943).idn-hostname(fix: Reject a trailing newline in idn-hostname #990).$refthrows instead of passing silently (Throw on an unresolvable $ref instead of passing silently #944). Like for Draft 2019-09, the test suite cases whose$refcannot be resolved yet are skipped.unevaluatedProperties: ECMA patterns (fix: Convert ECMA patterns in Draft 2019-09 unevaluatedProperties #998) and properties evaluated by a nestedunevaluatedProperties(fix: Count properties evaluated by a nested unevaluatedProperties in Draft 2019-09 #999).$refto$anchor, URN base URIs and ids next to$ref(fix: Resolve $ref to anchors, URN base URIs and ids beside $ref in Draft 2019-09 #970).enum(fix: Do not match numeric strings to numbers in enum #1001), and the schema is validated against its meta-schema in strict mode (fix: Validate the schema against its meta-schema in strict mode #973).unevaluatedItems(feat: Support unevaluatedItems in Draft 2019-09 #983), adapted to 2020-12:prefixItemsanditemsreplace the array form ofitemsandadditionalItems, and the items matched bycontainscount as evaluated, so they no longer have to form a prefix of the array.$dynamicRefis not followed, the same way$recursiveRefis not in Draft 2019-09.idn-hostnameis validated without ext-intl (fix: Throw a clear exception when idn-hostname validation lacks ext-intl #1009).Same limitations as Draft 2019-09, and the matching test cases are skipped:
$dynamicRef/$dynamicAnchorare not supported (the successors of$recursiveRef/$recursiveAnchor, which aren't supported in 2019-09 either).$vocabularyis not supported (optional/format-assertion.json).hostname,idn-hostnameandtimeformats, theregexformat, float overflow, …) are skipped for 2020-12 as well.Related Issue
Type of Change
Checklist
Additional Notes
This PR also contains the commits of other open PRs, so that Draft 2020-12 gets their fixes too. The last commit applies them to the Draft 2020-12 classes:
patternandpatternPropertiesin the non-strict mode, and the exact ECMA 262\sand\S.relative-json-pointerformat.uri,uri-referenceandemailformats as defined by RFC 3986 and RFC 5321.dependenciesfor compatibility in Draft 2019-09.Once those are merged, their commits drop out of this PR when it is rebased. #984 (
$recursiveRef) can be ported to Draft 2020-12 in the same way once it is merged.CHECK_MODE_FORMAT_ASSERTIONuses0x00000800, as #1007 (fail-fast) takes0x00000400.